// 查询列表接口
const getCategoryPage = (params) => {
    return $axios({
        url: '/department/getPage',
        method: 'get',
        params
    })
}
//导出excel表
const getExcel = () => {
    return $axios({
        url: '/department/export',
        method: 'get',
        responseType: 'blob' //表示返回的数据类型为二进制流
    }).then(res => {
        const content = res.data
        const blob = new Blob([content])
        const fileName = '全部部门信息'
        if ('download' in document.createElement('a')) { // 判断浏览器是否支持download属性
            const link = document.createElement('a')
            link.download = fileName
            link.style.display = 'none'
            link.href = URL.createObjectURL(blob)
            document.body.appendChild(link)
            link.click()
            URL.revokeObjectURL(link.href) // 释放URL对象所占用的内存
            document.body.removeChild(link)
        } else {
            navigator.msSaveBlob(blob, fileName)
        }
    })
}
// 查询列表接口
const getAll = () => {
    return $axios({
        url: '/department/getAll',
        method: 'get'
    })
}
// 编辑页面反查详情接口
const queryCategoryById = (id) => {
    return $axios({
        url: `/category/${id}`,
        method: 'get'
    })
}

// 删除当前列的接口
const deleCategory = (deId) => {
    return $axios({
        url: '/department',
        method: 'delete',
        params: {deId}
    })
}

// 修改接口
const editCategory = (data) => {
    return $axios({
        url: 'department/update',
        method: 'put',
        data: {
            did: data.dId,
            dname: data.dName,
            detail: data.detail
        }
    })
}

// 新增接口
const addCategory = (data) => {
    return $axios({
        url: '/department/add',
        method: 'post',
        data: {
            did: data.dId,
            dname: data.dName,
            detail: data.detail
        }
    })
}